package uw.illno.dao

import org.apache.ibatis.annotations.Delete
import org.apache.ibatis.annotations.Insert
import org.apache.ibatis.annotations.Select
import org.apache.ibatis.annotations.Update
import org.springframework.stereotype.Repository
import uw.illno.pojo.Student
import uw.illno.pojo.Teacher
import uw.illno.pojo.Admin

@Repository
interface AdministratorDao {
    //重置学生密码
    @Update("update student " + "set pwd = 123456 where sno=#{sno}")
    fun resetpwd(student: Student): Int

    //学生列表
    @Select("select * from student")
    fun findallStudent(): List<Student>

    //老师列表
    @Select("select * from teacher")
    fun findallTeacher(): List<Teacher>

    //管理员登录
    @Select("select pwd from admin where ano=#{ano}")
    fun acheck(admin: Admin): String?

    //学生登录
    @Select("select pwd from student where sno=#{sno}")
    fun scheck(student: Student): String?

    //老师登录
    @Select("select pwd from teacher where tno=#{tno}")
    fun tcheck(teacher: Teacher): String?

    //添加学生
    @Insert("insert into student (sno,sname,pwd,sex,sclass,phone,age) values (#{sno},#{sname},123456,#{sex},#{sclass},#{phone},#{age})")
    fun student_insert(student: Student): Int

    //删除学生
    @Delete("delete from student where sno=#{sno}")
    fun delete_student(student: Student):Int
}